<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = ["张三", "李四", "罗翔", "罗永浩"];
        //声明四个变量来就接受数组数组项；
        let [a, b, c, d] = arr;//完全解构
        console.log(a, b, c, d);
        //不完全解构
        let arr1=[1,2,3,4,5,6];
        let [e,f,g]=arr1;
        console.log(e,f,g);

        //设置缺少值
        let arr2=[1,2,3,4];
        //要求a3的值为4
        let[a1,a2,,a3]=arr2
        console.log(a1,a2,a3);
        //解构失败
        let arr3 = [1, 2, 3];
        let [b1, b2, b3, b4] = arr3;
        console.log(b1, b2, b3, b4);

        
        //解构默认值
        let arr4 = [1, 2, 3, ];
        let [c1, c2, c3, c4 = "呵呵"] = arr4;
        console.log(c1, c2, c3, c4);//如果解构失败 c4没有对应值就会赋值为默认值呵呵 否则 如果有对应值给c4赋值 就是用对应值给c4赋值 不用默认值
    </script>
   
</body>

</html>